import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { SWFPlayer } from "../../../scene/modle/SWFPlayer";
import { ModelType } from "../../../scene/modle/data/ModelType";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
type int = number;
//class CrossDefenceGuideBook
    
    export  class CrossDefenceGuideBook extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(672, 445);
            this._lastPage = -1;
            this.title = Language.getString(80324);
            this.titleHeight = 28;
            this._page.addEventListener(flash.events.Event.CHANGE, this.onPageChangeHandler);
            return;
        }

        public set data(arg1: Array<any>)
        {
            this._urls = arg1;
            if (this._urls == null || this._urls.length == 0) 
            {
                this._page.currentPage = 1;
                this._page.maxPage = 1;
                return;
            }
            this._page.currentPage = 1;
            this._page.maxPage = this._urls.length;
            this.updatePage();
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            this._lastPage = -1;
            this.updatePage();
            return;
        }

        protected updatePage(): void
        {
            if (this._urls == null || this._urls.length == 0 || this._lastPage == this._page.currentPage) 
            {
                return;
            }
            this._lastPage = this._page.currentPage;
            if (this._player == null) 
            {
                this._player = new SWFPlayer();
                this._player.sceneX = 222;
                this._player.sceneY = 244;
                this.addChild(this._player);
            }
            var loc1=this._urls[(this._page.currentPage - 1)];
            this._player.loadComplete = this.loadCompleted;
            this._player.load(loc1, ModelType.NormalSwf, null);
            return;
        }

        protected loadCompleted(arg1): void
        {
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            super.dispose();
            if (this._player != null) 
            {
                this._player.dispose(true);
                DisplayUtil.removeMe(this._player);
                this._player = null;
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(20, 43, 631, 361, this);
            this._page = ObjCreate.createPageSelecter(285, 412, this, PageSelecter.SingleMode);
            this._player = new SWFPlayer();
            this._player.sceneX = 222;
            this._player.sceneY = 244;
            this.addChild(this._player);
            return;
        }

        protected onPageChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this.updatePage();
            return;
        }

        protected /* var */_player: SWFPlayer;

        protected /* var */_page: PageSelecter;

        protected /* var */_lastPage: int;

        protected /* var */_urls: Array<any>;
    }
